﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Clock : MonoBehaviour {
    public Transform mHours;
    public Transform mMinutes;
    public Transform mSeconds;

    private const float hoursToDegrees = 360f / 12f;
    private const float minutesToDegrees = 360f / 60f;
    private const float secondsToDegrees = 360f / 60f;

    public bool analog;

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
        if (analog)
        {
            DateTime timespan = DateTime.Now;
            mHours.localRotation = Quaternion.Euler(0f, 0f, (float)timespan.Hour * -hoursToDegrees);
            mMinutes.localRotation = Quaternion.Euler(0f, 0f, (float)timespan.Minute * -minutesToDegrees);
            mSeconds.localRotation = Quaternion.Euler(0f, 0f, (float)timespan.Second * -secondsToDegrees);
        }
        else
        {
            TimeSpan timespan = DateTime.Now.TimeOfDay;
            mHours.localRotation = Quaternion.Euler(0f, 0f, (float)timespan.TotalHours * -hoursToDegrees);
            mMinutes.localRotation = Quaternion.Euler(0f, 0f, (float)timespan.TotalMinutes * -minutesToDegrees);
            mSeconds.localRotation = Quaternion.Euler(0f, 0f, (float)timespan.TotalSeconds * -secondsToDegrees);
        }
	}
}
